using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace CustomCMS.API.ObjectModel
{
	public class User
	{
		public User(string userId, string password, string actions)
		{
			_userId = userId;
			_password = password;
			_actions = actions;
		}

		private string _userId;

		public string UserId
		{
			get { return _userId; }
			set { _userId = value; }
		}

		private string _password;

		public string Password
		{
			get { return _password; }
			set { _password = value; }
		}

		private string _actions;

		public string Actions
		{
			get { return _actions; }
			set { _actions = value; }
		}

		public bool IsActionAllowed(string action)
		{
			if (action == "do_login") return true;

 			return ( Regex.IsMatch(_actions, "(?:^|,)" + action + "(?:,|$)") || _actions.ToLower().IndexOf("*admin*") != -1);
		}
	}
}
